home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / perlman / man / perl.txt < prev    next >
Encoding:
Text File  |  1999-09-09  |  13.6 KB  |  314 lines

  1. NAME
  2.        perl - Practical Extraction and Report Language
  3.  
  4. SYNOPSIS
  5.        perl [ -sTuU ]      [ -hv ] [ -V[:configvar] ]
  6.             [ -cw ] [ -d[:debugger] ] [ -D[number/list] ]
  7.             [ -pna ] [ -Fpattern ] [ -l[octal] ] [ -0[octal] ]
  8.             [ -Idir ] [ -m[-]module ] [ -M[-]'module...' ]
  9.             [ -P ]      [ -S ]      [ -x[dir] ]
  10.             [ -i[extension] ]
  11.             [ -e 'command' ] [ -- ] [ programfile ] [ argument ]...
  12.  
  13.        For ease of access, the Perl manual has been split up into
  14.        a number of sections:
  15.  
  16.            perl        Perl overview (this section)
  17.            perltoc     Perl documentation table of contents
  18.            perldata    Perl data structures
  19.            perlsyn     Perl syntax
  20.            perlop      Perl operators and precedence
  21.            perlre      Perl regular expressions
  22.            perlrun     Perl execution and options
  23.            perlfunc    Perl builtin functions
  24.            perlvar     Perl predefined variables
  25.            perlsub     Perl subroutines
  26.            perlmod     Perl modules
  27.            perlref     Perl references
  28.            perldsc     Perl data structures intro
  29.            perllol     Perl data structures: lists of lists
  30.            perlobj     Perl objects
  31.            perltie     Perl objects hidden behind simple variables
  32.            perlbot     Perl OO tricks and examples
  33.            perldebug   Perl debugging
  34.            perldiag    Perl diagnostic messages
  35.            perlform    Perl formats
  36.            perlipc     Perl interprocess communication
  37.            perlsec     Perl security
  38.            perltrap    Perl traps for the unwary
  39.            perlstyle   Perl style guide
  40.            perlxs      Perl XS application programming interface
  41.            perlxstut   Perl XS tutorial
  42.            perlguts    Perl internal functions for those doing extensions
  43.            perlcall    Perl calling conventions from C
  44.            perlembed   Perl how to embed perl in your C or C++ app
  45.            perlpod     Perl plain old documentation
  46.            perlbook    Perl book information
  47.  
  48.        (If you're intending to read these straight through for
  49.        the first time, the suggested order will tend to reduce
  50.        the number of forward references.)
  51.  
  52.        Additional documentation for Perl modules is available in
  53.        the /usr/local/man/ directory.  Some of this is
  54.        distributed standard with Perl, but you'll also find
  55.        third-party modules there.  You should be able to view
  56.        this with your man(1) program by including the proper
  57.        directories in the appropriate start-up files.  To find
  58.        out where these are, type:
  59.  
  60.            perl -le 'use Config; print "@Config{man1dir,man3dir}"'
  61.  
  62.        If the directories were /usr/local/man/man1 and
  63.        /usr/local/man/man3, you would only need to add
  64.        /usr/local/man to your MANPATH.  If they are different,
  65.        you'll have to add both stems.
  66.  
  67.        If that doesn't work for some reason, you can still use
  68.        the supplied perldoc script to view module information.
  69.        You might also look into getting a replacement man
  70.        program.
  71.  
  72.        If something strange has gone wrong with your program and
  73.        you're not sure where you should look for help, try the -w
  74.        switch first.  It will often point out exactly where the
  75.        trouble is.
  76.  
  77. DESCRIPTION
  78.        Perl is an interpreted language optimized for scanning
  79.        arbitrary text files, extracting information from those
  80.        text files, and printing reports based on that
  81.        information.  It's also a good language for many system
  82.        management tasks.  The language is intended to be
  83.        practical (easy to use, efficient, complete) rather than
  84.        beautiful (tiny, elegant, minimal).
  85.  
  86.        Perl combines (in the author's opinion, anyway) some of
  87.        the best features of C, sed, awk, and sh, so people
  88.        familiar with those languages should have little
  89.        difficulty with it.  (Language historians will also note
  90.        some vestiges of csh, Pascal, and even BASIC-PLUS.)
  91.        Expression syntax corresponds quite closely to C
  92.        expression syntax.  Unlike most Unix utilities, Perl does
  93.        not arbitrarily limit the size of your data--if you've got
  94.        the memory, Perl can slurp in your whole file as a single
  95.        string.  Recursion is of unlimited depth.  And the hash
  96.        tables used by associative arrays grow as necessary to
  97.        prevent degraded performance.  Perl uses sophisticated
  98.        pattern matching techniques to scan large amounts of data
  99.        very quickly.  Although optimized for scanning text, Perl
  100.        can also deal with binary data, and can make dbm files
  101.        look like associative arrays.  Setuid Perl scripts are
  102.        safer than C programs through a dataflow tracing mechanism
  103.        which prevents many stupid security holes.  If you have a
  104.        problem that would ordinarily use sed or awk or sh, but it
  105.        exceeds their capabilities or must run a little faster,
  106.        and you don't want to write the silly thing in C, then
  107.        Perl may be for you.  There are also translators to turn
  108.        your sed and awk scripts into Perl scripts.
  109.        But wait, there's more...
  110.  
  111.        Perl version 5 is nearly a complete rewrite, and provides
  112.        the following additional benefits:
  113.  
  114.        o Many usability enhancements
  115.             It is now possible to write much more readable Perl
  116.             code (even within regular expressions).  Formerly
  117.             cryptic variable names can be replaced by mnemonic
  118.             identifiers.  Error messages are more informative,
  119.             and the optional warnings will catch many of the
  120.             mistakes a novice might make.  This cannot be
  121.             stressed enough.  Whenever you get mysterious
  122.             behavior, try the -w switch!!!  Whenever you don't
  123.             get mysterious behavior, try using -w anyway.
  124.  
  125.        o Simplified grammar
  126.             The new yacc grammar is one half the size of the old
  127.             one.  Many of the arbitrary grammar rules have been
  128.             regularized.  The number of reserved words has been
  129.             cut by 2/3.  Despite this, nearly all old Perl
  130.             scripts will continue to work unchanged.
  131.  
  132.        o Lexical scoping
  133.             Perl variables may now be declared within a lexical
  134.             scope, like "auto" variables in C.  Not only is this
  135.             more efficient, but it contributes to better privacy
  136.             for "programming in the large".
  137.  
  138.        o Arbitrarily nested data structures
  139.             Any scalar value, including any array element, may
  140.             now contain a reference to any other variable or
  141.             subroutine.  You can easily create anonymous
  142.             variables and subroutines.  Perl manages your
  143.             reference counts for you.
  144.  
  145.        o Modularity and reusability
  146.             The Perl library is now defined in terms of modules
  147.             which can be easily shared among various packages.  A
  148.             package may choose to import all or a portion of a
  149.             module's published interface.  Pragmas (that is,
  150.             compiler directives) are defined and used by the same
  151.             mechanism.
  152.  
  153.        o Object-oriented programming
  154.             A package can function as a class.  Dynamic multiple
  155.             inheritance and virtual methods are supported in a
  156.             straightforward manner and with very little new
  157.             syntax.  Filehandles may now be treated as objects.
  158.  
  159.        o Embeddable and Extensible
  160.             Perl may now be embedded easily in your C or C++
  161.             application, and can either call or be called by your
  162.             routines through a documented interface.  The XS
  163.             preprocessor is provided to make it easy to glue your
  164.             C or C++ routines into Perl.  Dynamic loading of
  165.             modules is supported.
  166.  
  167.        o POSIX compliant
  168.             A major new module is the POSIX module, which
  169.             provides access to all available POSIX routines and
  170.             definitions, via object classes where appropriate.
  171.  
  172.        o Package constructors and destructors
  173.             The new BEGIN and END blocks provide means to capture
  174.             control as a package is being compiled, and after the
  175.             program exits.  As a degenerate case they work just
  176.             like awk's BEGIN and END when you use the -p or -n
  177.             switches.
  178.  
  179.        o Multiple simultaneous DBM implementations
  180.             A Perl program may now access DBM, NDBM, SDBM, GDBM,
  181.             and Berkeley DB files from the same script
  182.             simultaneously.  In fact, the old dbmopen interface
  183.             has been generalized to allow any variable to be tied
  184.             to an object class which defines its access methods.
  185.  
  186.        o Subroutine definitions may now be autoloaded
  187.             In fact, the AUTOLOAD mechanism also allows you to
  188.             define any arbitrary semantics for undefined
  189.             subroutine calls.  It's not just for autoloading.
  190.  
  191.        o Regular expression enhancements
  192.             You can now specify non-greedy quantifiers.  You can
  193.             now do grouping without creating a backreference.
  194.             You can now write regular expressions with embedded
  195.             whitespace and comments for readability.  A
  196.             consistent extensibility mechanism has been added
  197.             that is upwardly compatible with all old regular
  198.             expressions.
  199.  
  200.        Ok, that's definitely enough hype.
  201.  
  202. ENVIRONMENT
  203.        HOME        Used if chdir has no argument.
  204.  
  205.        LOGDIR      Used if chdir has no argument and HOME is not
  206.                    set.
  207.  
  208.        PATH        Used in executing subprocesses, and in finding
  209.                    the script if -S is used.
  210.  
  211.        PERL5LIB    A colon-separated list of directories in which
  212.                    to look for Perl library files before looking
  213.                    in the standard library and the current
  214.                    directory.  If PERL5LIB is not defined,
  215.                    PERLLIB is used.  When running taint checks
  216.                    (because the script was running setuid or
  217.                    setgid, or the -T switch was used), neither
  218.                    variable is used.  The script should instead
  219.                    say
  220.  
  221.                        use lib "/my/directory";
  222.  
  223.        PERL5DB     The command used to get the debugger code.  If
  224.                    unset, uses
  225.  
  226.                            BEGIN { require 'perl5db.pl' }
  227.  
  228.        PERLLIB     A colon-separated list of directories in which
  229.                    to look for Perl library files before looking
  230.                    in the standard library and the current
  231.                    directory.  If PERL5LIB is defined, PERLLIB is
  232.                    not used.
  233.  
  234.        Apart from these, Perl uses no other environment
  235.        variables, except to make them available to the script
  236.        being executed, and to child processes.  However, scripts
  237.        running setuid would do well to execute the following
  238.        lines before doing anything else, just to keep people
  239.        honest:
  240.  
  241.            $ENV{'PATH'} = '/bin:/usr/bin';    # or whatever you need
  242.            $ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'};
  243.            $ENV{'IFS'} = ''          if defined $ENV{'IFS'};
  244.  
  245. AUTHOR
  246.        Larry Wall <lwall@sems.com>, with the help of oodles of
  247.        other folks.
  248.  
  249. FILES
  250.         "/tmp/perl-e$$"        temporary file for -e commands
  251.         "@INC"                 locations of perl 5 libraries
  252.  
  253. SEE ALSO
  254.         a2p    awk to perl translator
  255.  
  256.         s2p    sed to perl translator
  257.  
  258. DIAGNOSTICS
  259.        The -w switch produces some lovely diagnostics.
  260.  
  261.        See the perldiag manpage for explanations of all Perl's
  262.        diagnostics.
  263.  
  264.        Compilation errors will tell you the line number of the
  265.        error, with an indication of the next token or token type
  266.        that was to be examined.  (In the case of a script passed
  267.        to Perl via -e switches, each -e is counted as one line.)
  268.  
  269.        Setuid scripts have additional constraints that can
  270.        produce error messages such as "Insecure dependency".  See
  271.        the perlsec manpage.
  272.  
  273.        Did we mention that you should definitely consider using
  274.        the -w switch?
  275.  
  276. BUGS
  277.        The -w switch is not mandatory.
  278.  
  279.        Perl is at the mercy of your machine's definitions of
  280.        various operations such as type casting, atof() and
  281.        sprintf().  The latter can even trigger a coredump when
  282.        passed ludicrous input values.
  283.  
  284.        If your stdio requires a seek or eof between reads and
  285.        writes on a particular stream, so does Perl.  (This
  286.        doesn't apply to sysread() and syswrite().)
  287.  
  288.        While none of the built-in data types have any arbitrary
  289.        size limits (apart from memory size), there are still a
  290.        few arbitrary limits:  a given identifier may not be
  291.        longer than 255 characters, and no component of your PATH
  292.        may be longer than 255 if you use -S.  A regular
  293.        expression may not compile to more than 32767 bytes
  294.        internally.
  295.  
  296.        See the perl bugs database at  http://perl.com/perl/bugs/
  297.        .  You may mail your bug reports (be sure to include full
  298.        configuration information as output by the myconfig
  299.        program in the perl source tree) to perlbug@perl.com.  If
  300.        you've succeeded in compiling perl, the perlbug script in
  301.        the utils/ subdirectory can be used to help mail in a bug
  302.        report.
  303.  
  304.        Perl actually stands for Pathologically Eclectic Rubbish
  305.        Lister, but don't tell anyone I said that.
  306.  
  307. NOTES
  308.        The Perl motto is "There's more than one way to do it."
  309.        Divining how many more is left as an exercise to the
  310.        reader.
  311.  
  312.        The three principal virtues of a programmer are Laziness,
  313.        Impatience, and Hubris.  See the Camel Book for why.
  314.